﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.SessionState;
using System.Text;
using System.Web.Security;
using Royalsoft.Common;

namespace NJL.Web
{
    /// <summary>
    /// 用户信息类
    /// </summary>
    public class UserInfo
    {
        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName
        {
            get;
            set;
        }
        /// <summary>
        /// 用户头像路径
        /// </summary>
        public string UserImage
        {
            get;
            set;
        }
        /// <summary>
        /// 关注人数
        /// </summary>
        public string AttentionCount
        {
            get;
            set;
        }
        /// <summary>
        /// 被关注次数
        /// </summary>
        public string AttentionCounted
        {
            get;
            set;
        }
        /// <summary>
        /// 文章个数
        /// </summary>
        public string NewsCount
        {
            get;
            set;
        }
        /// <summary>
        /// 是否显示关注
        /// </summary>
        public string IsDisPlayAttention
        {
            get;
            set;
        }
        /// <summary>
        /// 是否显示添加关注或取消关注
        /// </summary>
        public string IsDisPlayAttentionAndCancel
        {
            get;
            set;
        }

    }
    public class Area
    {
        /// <summary>
        /// 自定义区域编号
        /// </summary>
        public string AreaID
        {
            get;
            set;
        }
        /// <summary>
        /// 自定义区域名称
        /// </summary>
        public string AreaName
        {
            get;
            set;
        }
    }
    /// <summary>
    /// Handler 的摘要说明
    /// </summary>
    public class Handler : IHttpHandler, IRequiresSessionState
    {
        /// <summary>
        /// 想买
        /// </summary>
        public string XiangMai
        {
            get;
            set;
        }
        public string MaiGuo
        {
            get;
            set;
        }

        NJL.BLL.NJL_MYFRIEND bllFriend = new BLL.NJL_MYFRIEND();

        NJL.BLL.NJL_USER bllUser = new BLL.NJL_USER();
        public void ProcessRequest(HttpContext context)
        {
            BasePage basepage = new BasePage();
            context.Response.ContentType = "text/plain";
            if (context.Request.QueryString["UserName"] != null)
            {
                string userName = context.Request.QueryString["UserName"].ToString();
                if (bllUser.GetUserNameByName(userName))
                {
                    context.Response.Write("NO");
                }
            }
            else if (context.Request.QueryString["QQ"] != null)
            {
                string qq = context.Request.QueryString["QQ"].ToString();
                if (bllUser.GetQQByQQ(qq))
                {
                    context.Response.Write("NOQQ");
                }
            }
            else if (context.Request.QueryString["CellPhoneNumber"] != null)
            {
                string CellPhoneNumber = context.Request.QueryString["CellPhoneNumber"].ToString();
                if (bllUser.GetCellPhoneByCellPhoneNumber(CellPhoneNumber))
                {
                    context.Response.Write("NOCellPhoneNumber");
                }
            }
            else if (context.Request.QueryString["Email"] != null)
            {
                string txtEmail = context.Request.QueryString["Email"].ToString();
                if (bllUser.GetEmailPhoneByEmail(txtEmail))
                {
                    context.Response.Write("NOEmail");
                }
            }
            else if (context.Request.QueryString["userid"] != null)
            {
                if (context.Session["userid"] == null)
                {
                    context.Response.Write("nologin");
                    return;
                }
                NJL.Model.NJL_MYFRIEND modelFriend;
                string userId = context.Request.QueryString["userid"].ToString();
                DataSet ds = bllFriend.GetList("NJL_MYFRIEND.FRIEND_USER_ID=" + userId + " and NJL_MYFRIEND.NJL_USER_ID=" + context.Session["userid"].ToString());
                if (ds.Tables[0].Rows.Count > 0)
                {
                    context.Response.Write("false");
                }
                else
                {
                    modelFriend = new Model.NJL_MYFRIEND();
                    modelFriend.ID = DateTime.Now.ToString("yyyyMMddHHmmssfff") + new Random().Next(100, 999).ToString();
                    modelFriend.FRIEND_USER_ID = userId;
                    modelFriend.NJL_USER_ID = context.Session["userid"].ToString();
                    modelFriend.CREATE_DATE_TIME = DateTime.Now;
                    modelFriend.CREATE_USER_ID = context.Session["userid"].ToString();
                    modelFriend.CREATE_USER_NAME = context.Session["username"].ToString();
                    if (bllFriend.Add(modelFriend))
                    {

                        context.Response.Write("true");
                        string message;
                        if (new BasePageVisitor().HandleIntegral(context.Session["userid"].ToString(), "4", out message))
                        {

                        }
                    }
                }

            }
            else if (context.Request.QueryString["deleteFriend"] != null)
            {
                string userid = context.Request.QueryString["deleteFriend"].ToString();
                DataSet ds = bllFriend.GetList("NJL_MYFRIEND.FRIEND_USER_ID='" + userid + "' and NJL_MYFRIEND.NJL_USER_ID='" + context.Session["userid"].ToString() + "'");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (bllFriend.Delete(ds.Tables[0].Rows[0]["ID2"].ToString()))
                    {

                        context.Response.Write("true");
                        string message;
                        if (new BasePageVisitor().HandleIntegral(context.Session["userid"].ToString(), "-4", out message))
                        {

                        }
                    }
                }

            }
            else if (context.Request.Form["sendUserid"] != null && context.Request.Form["content"] != null)
            {
                string sendUserid = context.Request.Form["sendUserid"].ToString();
                string content = context.Request.Form["content"].ToString();
                NJL.BLL.NJL_MESSAGES bllMessage = new BLL.NJL_MESSAGES();
                Model.NJL_MESSAGES modelMessage = new Model.NJL_MESSAGES();
                modelMessage.ID = DateTime.Now.ToString("yyyyMMddHHmmssfff") + new Random().Next(100, 999).ToString();
                modelMessage.CREATE_USER_ID = context.Session["userid"].ToString();
                modelMessage.CREATE_USER_NAME = context.Session["username"].ToString();
                modelMessage.TO_USER_ID = sendUserid;
                modelMessage.MESSAGE_CONTENT = content;
                modelMessage.CREATE_DATE_TIME = DateTime.Now;
                modelMessage.MESSAGE_TYPE = 2; //2代表个人
                if (bllMessage.Add(modelMessage))
                {
                    context.Response.Write("true");
                }
            }
            else if (context.Request.QueryString["companyEvaluation"] != null && context.Request.QueryString["content"] != null && context.Request.QueryString["typecode"] != null)
            {


                NJL.BLL.NJL_COMPANY_EVALUATION bll = new BLL.NJL_COMPANY_EVALUATION();
                NJL.Model.NJL_COMPANY_EVALUATION model = new Model.NJL_COMPANY_EVALUATION();
                string companyId = context.Request.QueryString["companyEvaluation"].ToString();
                string commentContent = context.Request.QueryString["content"].ToString();
                model.ID = DateTime.Now.ToString("yyyyMMddHHmmssfff") + new Random().Next(100, 999).ToString();
                model.NJL_COMPANY_ID = companyId;
                model.EVALUATION_TYPE_CODE = Convert.ToInt32(context.Request.QueryString["typecode"]);
                if (context.Session["userid"] != null && context.Session["username"] != null)
                {
                    model.CREATE_USER_ID = context.Session["userid"].ToString();
                    model.CREATE_USER_NAME = context.Session["username"].ToString();
                }
                model.CREATE_DATE_TIME = DateTime.Now;
                model.COMPANY_EVALUATION = commentContent;
                if (bll.Add(model))
                {
                    context.Response.Write(commentContent);
                }

            }
            else if (context.Request.Form["city"] != null)
            {
                DataSet ds;
                string cityId = context.Request.Form["city"];
                NJL.BLL.NJL_CS_AREA bllArea = new BLL.NJL_CS_AREA();
                NJL.Model.NJL_CS_AREA modelArea = bllArea.GetModel(cityId);
                NJL.BLL.NJL_COMPANY bllCompany = new BLL.NJL_COMPANY();
                int njxy;
                int djsz;
                int jdms;
                int dfts;
                if (cityId == "110000" || cityId == "120000" || cityId == "310000" || cityId == "500000")
                {
                    ds = bllCompany.GetAllList("TYPE_CODE='1' and NJL_SYS_BASE_ID='" + cityId + "'");
                    njxy = ds.Tables[0].Rows.Count;
                    ds = bllCompany.GetAllList("TYPE_CODE='2' and NJL_SYS_BASE_ID='" + cityId + "'");
                    djsz = ds.Tables[0].Rows.Count;
                    NJL.BLL.NJL_ATTRACTION bllAttr = new BLL.NJL_ATTRACTION();
                    ds = bllAttr.GetAllList("NJL_SYS_BASE_ID='" + cityId + "'");
                    jdms = ds.Tables[0].Rows.Count;
                    NJL.BLL.NJL_LOCAL_COLOR bllLocal = new BLL.NJL_LOCAL_COLOR();
                    ds = bllLocal.GetAllList("NJL_SYS_BASE_ID='" + cityId + "'");
                    dfts = ds.Tables[0].Rows.Count;
                }
                else
                {
                    ds = bllCompany.GetAllList("TYPE_CODE='1' and AREA_CODE='" + cityId + "'");
                    njxy = ds.Tables[0].Rows.Count;
                    ds = bllCompany.GetAllList("TYPE_CODE='2' and AREA_CODE='" + cityId + "'");
                    djsz = ds.Tables[0].Rows.Count;
                    NJL.BLL.NJL_ATTRACTION bllAttr = new BLL.NJL_ATTRACTION();
                    ds = bllAttr.GetAllList("AREA_CODE='" + cityId + "'");
                    jdms = ds.Tables[0].Rows.Count;
                    NJL.BLL.NJL_LOCAL_COLOR bllLocal = new BLL.NJL_LOCAL_COLOR();
                    ds = bllLocal.GetAllList("AREA_CODE='" + cityId + "'");
                    dfts = ds.Tables[0].Rows.Count;
                }
                context.Response.Write(modelArea.NJL_DESCRIPTION + "," + modelArea.AREA_NAME + "," + njxy + "," + djsz + "," + jdms + "," + dfts);
            }
            else if (context.Request.QueryString["validateCode"] != null)
            {
                string validateCode = context.Request.QueryString["validateCode"];
                if (context.Session["CheckCode"] != null && validateCode.ToLower() == context.Session["CheckCode"].ToString().ToLower())
                {
                    context.Response.Write("Ture");
                }
                else
                {
                    context.Response.Write("False");
                }
            }
            else if (context.Request.QueryString["collection"] != null && context.Request.QueryString["collType"] != null)
            {
                if (context.Session["userid"] == null && context.Session["username"] == null)
                {
                    context.Response.Write("NoSession");
                }
                else
                {
                    NJL.BLL.NJL_MY_COLLECTION bll = new BLL.NJL_MY_COLLECTION();
                    NJL.Model.NJL_MY_COLLECTION model = new Model.NJL_MY_COLLECTION();
                    string collectionID = context.Request.QueryString["collection"];
                    string collType = context.Request.QueryString["collType"];
                    DataSet ds = bll.GetList("NJL_USER_ID='" + context.Session["userid"].ToString() + "' and TARGET_ID='" + collectionID + "' and COLLECTION_TYPE='" + collType + "'");
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        context.Response.Write("False");
                    }
                    else
                    {
                        model.ID = DateTime.Now.ToString("yyyyMMddHHmmssfff") + new Random().Next(100, 999).ToString();
                        model.CREATE_USER_ID = context.Session["userid"].ToString();
                        model.CREATE_USER_NAME = context.Session["username"].ToString();
                        model.CREATE_DATE_TIME = DateTime.Now;
                        model.TARGET_ID = collectionID;
                        model.NJL_USER_ID = context.Session["userid"].ToString();
                        model.COLLECTION_TYPE = collType;
                        if (bll.Add(model))
                        {
                            ds = bll.GetList("TARGET_ID='" + collectionID + "' and COLLECTION_TYPE='" + collType + "'");
                            context.Response.Write(ds.Tables[0].Rows.Count.ToString());
                        }
                    }
                }
            }
            else if (context.Request.QueryString["companyid"] != null && context.Request.QueryString["typecode"] != null)
            {
                NJL.BLL.NJL_COMPANY_EVALUATION bll = new BLL.NJL_COMPANY_EVALUATION();

                IList<Model.NJL_COMPANY_EVALUATION> modelList = bll.GetModelList("NJL_COMPANY_ID='" + context.Request.QueryString["companyid"] + "' AND EVALUATION_TYPE_CODE=" + context.Request.QueryString["typecode"].ToString());

                context.Response.Write(modelList.Count.ToString());
            }
            else if (context.Request.QueryString["sessionUrl"] != null)
            {
                string url = context.Server.UrlDecode(context.Request.QueryString["sessionUrl"]);
                //context.Session["url"] = url;
                context.Session.Add("url", url);
            }
            else if (context.Request.QueryString["SecondsessionUrl"] != null)
            {
                string url = context.Request.QueryString["SecondsessionUrl"];
                //context.Session["secondurl"] = url;
                context.Session.Add("secondurl", url);
            }
            else if (context.Request.QueryString["supportobjectid"] != null && context.Request.QueryString["supporttypecode"] != null && context.Request.QueryString["option"] == "getcount")
            {
                NJL.BLL.NJL_REG_SUPPORT bll = new BLL.NJL_REG_SUPPORT();
                string strObjectID = context.Request.QueryString["supportobjectid"];
                string strSupportType = context.Request.QueryString["supporttypecode"];//1：农家乐，2：景点，3：地方特色

                IList<Model.NJL_REG_SUPPORT> list = bll.GetModelList(" SUPPORT_OBJECT_TYPE=" + strSupportType + " AND SUPPORT_OBJECT_ID='" + strObjectID + "' ");
                context.Response.Write(list.Count.ToString());
            }
            else if (context.Request.QueryString["supportobjectid"] != null && context.Request.QueryString["supporttypecode"] != null)
            {
                NJL.BLL.NJL_REG_SUPPORT bll = new BLL.NJL_REG_SUPPORT();

                string strObjectID = context.Request.QueryString["supportobjectid"];
                string strSupportType = context.Request.QueryString["supporttypecode"];//1：农家乐，2：景点，3：地方特色
                string strIP = context.Request.UserHostAddress;//客户端IP
                DateTime dtime = System.DateTime.Now;

                //
                IList<Model.NJL_REG_SUPPORT> list = bll.GetModelList(1, " SUPPORT_OBJECT_TYPE=" + strSupportType + " AND SUPPORT_OBJECT_ID='" + strObjectID + "' AND IP='" + strIP + "' ", "CREATE_DATE_TIME DESC");

                if (list.Count == 1)
                {
                    if ((dtime - list[0].CREATE_DATE_TIME.Value).TotalMinutes < 5)
                    {
                        context.Response.Write("NO");
                    }
                    else
                    {
                        NJL.Model.NJL_REG_SUPPORT model = new Model.NJL_REG_SUPPORT();

                        model.ID = dtime.ToString("yyyyMMddHHmmssfff") + new Random().Next(100, 999).ToString();
                        model.SUPPORT_OBJECT_TYPE = Convert.ToInt32(strSupportType);
                        model.SUPPORT_OBJECT_ID = strObjectID;
                        model.IP = strIP;
                        model.CREATE_DATE_TIME = dtime;

                        bll.Add(model);

                        if (strSupportType == "1")
                        {
                            NJL.BLL.NJL_COMPANY bllCompany = new BLL.NJL_COMPANY();
                            NJL.Model.NJL_COMPANY modelCompany = bllCompany.GetModel(strObjectID);
                            modelCompany.SUPPORT_COUNT = bll.GetModelList(" SUPPORT_OBJECT_TYPE=" + strSupportType + " AND SUPPORT_OBJECT_ID='" + strObjectID + "' ").Count;
                            bllCompany.Update(modelCompany);
                        }
                        else if (strSupportType == "2")
                        {
                            NJL.BLL.NJL_ATTRACTION bllAttr = new BLL.NJL_ATTRACTION();
                            NJL.Model.NJL_ATTRACTION modelAttr = bllAttr.GetModel(strObjectID);
                            modelAttr.SUPPORT_COUNT = bll.GetModelList(" SUPPORT_OBJECT_TYPE=" + strSupportType + " AND SUPPORT_OBJECT_ID='" + strObjectID + "' ").Count;
                            bllAttr.Update(modelAttr);
                        }

                        context.Response.Write("OK");
                    }
                }
                else
                {
                    NJL.Model.NJL_REG_SUPPORT model = new Model.NJL_REG_SUPPORT();

                    model.ID = dtime.ToString("yyyyMMddHHmmssfff") + new Random().Next(100, 999).ToString();
                    model.SUPPORT_OBJECT_TYPE = Convert.ToInt32(strSupportType);
                    model.SUPPORT_OBJECT_ID = strObjectID;
                    model.IP = strIP;
                    model.CREATE_DATE_TIME = dtime;

                    bll.Add(model);

                    if (strSupportType == "1")
                    {
                        NJL.BLL.NJL_COMPANY bllCompany = new BLL.NJL_COMPANY();
                        NJL.Model.NJL_COMPANY modelCompany = bllCompany.GetModel(strObjectID);
                        modelCompany.SUPPORT_COUNT = bll.GetModelList(" SUPPORT_OBJECT_TYPE=" + strSupportType + " AND SUPPORT_OBJECT_ID='" + strObjectID + "' ").Count;
                        bllCompany.Update(modelCompany);
                    }
                    else if (strSupportType == "2")
                    {
                        NJL.BLL.NJL_ATTRACTION bllAttr = new BLL.NJL_ATTRACTION();
                        NJL.Model.NJL_ATTRACTION modelAttr = bllAttr.GetModel(strObjectID);
                        modelAttr.SUPPORT_COUNT = bll.GetModelList(" SUPPORT_OBJECT_TYPE=" + strSupportType + " AND SUPPORT_OBJECT_ID='" + strObjectID + "' ").Count;
                        bllAttr.Update(modelAttr);
                    }
                    context.Response.Write("OK");
                }

                context.Response.Write("");
            }
            else if (context.Request.Form["localColorID"] != null && context.Request.Form["localColorID"] != "")
            {
                NJL.BLL.NJL_REG_SUPPORT bll = new BLL.NJL_REG_SUPPORT();
                NJL.Model.NJL_REG_SUPPORT model = new Model.NJL_REG_SUPPORT();
                string localColorID = context.Request.Form["localColorID"];
                string typeId = context.Request.Form["typeId"];
                string objTypeId = context.Request.Form["objTypeId"];  //1想买,1买过
                model.ID = DateTime.Now.ToString("yyyyMMddHHmmssfff") + new Random().Next(100, 999).ToString();
                model.SUPPORT_OBJECT_ID = localColorID;
                model.SUPPORT_TYPE_CODE = int.Parse(typeId);
                model.SUPPORT_OBJECT_TYPE = int.Parse(objTypeId);
                model.IP = context.Request.UserHostAddress;
                model.CREATE_DATE_TIME = DateTime.Now;

                //ds = bll.GetList(1, "IP='" + context.Request.UserHostAddress + "' and SUPPORT_OBJECT_TYPE='" + objTypeId + "' and SUPPORT_OBJECT_ID='" + localColorID + "' and SUPPORT_TYPE_CODE='" + typeId + "' and DateDiff(n,CREATE_DATE_TIME,GetDate())>5", "CREATE_DATE_TIME desc");
                IList<Model.NJL_REG_SUPPORT> list = bll.GetModelList(1, "IP='" + context.Request.UserHostAddress + "' and SUPPORT_OBJECT_TYPE='" + objTypeId + "' and SUPPORT_OBJECT_ID='" + localColorID + "' and SUPPORT_TYPE_CODE='" + typeId + "'", "CREATE_DATE_TIME desc");
                if (list.Count > 0)
                {
                    context.Response.Write("您已提交过");
                }
                else
                {
                    if (bll.Add(model))
                    {
                        object count = bll.GetListCount(objTypeId, localColorID, typeId);
                        context.Response.Write(count.ToString());
                    }
                }

            }

            else if (context.Request.Form["localColorIDCount"] != null && context.Request.Form["localColorIDCount"] != "")
            {
                NJL.BLL.NJL_REG_SUPPORT bll = new BLL.NJL_REG_SUPPORT();
                NJL.Model.NJL_REG_SUPPORT model = new Model.NJL_REG_SUPPORT();
                string localColorID = context.Request.Form["localColorIDCount"];
                string typeId = context.Request.Form["typeId"];
                object xm = bll.GetListCount("1", localColorID, typeId);
                object mg = bll.GetListCount("2", localColorID, typeId);
                Handler hand = new Handler();
                hand.XiangMai = xm.ToString();
                hand.MaiGuo = mg.ToString();
                string jsonString = Royalsoft.Common.JsonHelper.JsonSerializer<Handler>(hand);
                context.Response.Write(jsonString);
            }
            //用户手机验证-生成验证码
            else if (context.Request.QueryString["userinfochecktype"] != null && context.Request.QueryString["checkcodetype"] != null && context.Request.QueryString["mobile"] != null && context.Request.QueryString["checkcode"] != null)
            {
                string strUserInfoCheckType = context.Request.QueryString["userinfochecktype"];
                string strCheckCodeType = context.Request.QueryString["checkcodetype"];
                string strMobile = context.Request.QueryString["mobile"];
                string strCheckCode = context.Request.QueryString["checkcode"];

                NJL.BLL.NJL_USER bll = new BLL.NJL_USER();
                NJL.BLL.NJL_REG_SMS_CHECK bllSms = new BLL.NJL_REG_SMS_CHECK();

                if (strUserInfoCheckType == "create")
                {

                    NJL.Model.NJL_USER model = bll.GetModel(context.Session["userid"].ToString());
                    IList<NJL.Model.NJL_REG_SMS_CHECK> modelList = bllSms.GetModelList("CREATE_DATE_TIME>'" + System.DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00' and CREATE_DATE_TIME<'" + System.DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00'");

                    if (modelList.Count >= 3)
                    {
                        context.Response.Write("OVER");
                    }
                    else
                    {
                        model.MOBILE = strMobile;
                        model.AUTHENTICATION_CODE_MOBILE = new Random().Next(0, 9999).ToString("0000");
                        bll.Update(model);

                        string i = new NJL.Web.BasePage().SendSMS(strMobile, "感谢您使用" + System.Configuration.ConfigurationManager.AppSettings["WebSiteName"] + ",您的验证码为：" + model.AUTHENTICATION_CODE_MOBILE + ".【" + System.Configuration.ConfigurationManager.AppSettings["WebSiteName"] + "】");

                        Model.NJL_REG_SMS_CHECK modelSMS = new Model.NJL_REG_SMS_CHECK();
                        modelSMS.ID = DateTime.Now.ToString("yyyyMMddHHmmssfff") + new Random().Next(0, 999).ToString("000");
                        bllSms.Add(modelSMS);
                        context.Response.Write("OK");
                    }
                }

                else if (strUserInfoCheckType == "get")
                {
                    NJL.Model.NJL_USER model = bll.GetModel(context.Session["userid"].ToString());

                    if (model.AUTHENTICATION_CODE_MOBILE == strCheckCode)
                    {
                        model.MOBILE_ACTIVE = 1;
                        bll.Update(model);
                        context.Response.Write("OK");
                    }
                    else
                    {
                        context.Response.Write("ERROR");
                    }
                }

                else if (strUserInfoCheckType == "editmobile")
                {
                    NJL.Model.NJL_USER model = bll.GetModel(context.Session["userid"].ToString());
                    IList<NJL.Model.NJL_REG_SMS_CHECK> modelList = bllSms.GetModelList("CREATE_DATE_TIME>'" + System.DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00' and CREATE_DATE_TIME<'" + System.DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00'");

                    if (modelList.Count >= 3)
                    {
                        context.Response.Write("OVER");
                    }
                    else
                    {
                        model.MOBILE = strMobile;
                        model.MOBILE_ACTIVE = 0;
                        model.AUTHENTICATION_CODE_MOBILE = new Random().Next(0, 9999).ToString("0000");
                        bll.Update(model);

                        string i = new NJL.Web.BasePage().SendSMS(strMobile, "感谢您使用" + System.Configuration.ConfigurationManager.AppSettings["WebSiteName"] + ",您修改后的手机号码为：" + strMobile + ",验证码为：" + model.AUTHENTICATION_CODE_MOBILE + "，请尽快验证。【" + System.Configuration.ConfigurationManager.AppSettings["WebSiteName"] + "】");

                        Model.NJL_REG_SMS_CHECK modelSMS = new Model.NJL_REG_SMS_CHECK();
                        modelSMS.ID = DateTime.Now.ToString("yyyyMMddHHmmssfff") + new Random().Next(0, 999).ToString("000");
                        bllSms.Add(modelSMS);
                        context.Response.Write("OK");
                    }
                }
            }
            else if (context.Request.QueryString["remind"] != null && context.Request.QueryString["remind"] != "")
            {
                string shopId = context.Request.QueryString["remind"];
                NJL.BLL.NJL_COMPANY bllCompany = new BLL.NJL_COMPANY();
                NJL.Model.NJL_COMPANY modelCompany = bllCompany.GetModel(shopId);
                modelCompany.VISITOR_ALERT_COUNT += 1;
                if (bllCompany.Update(modelCompany))
                {
                    context.Response.Write("True");
                }

            }
            else if (context.Request.QueryString["remindCountId"] != null && context.Request.QueryString["remindCountId"] != "")
            {
                string shopId = context.Request.QueryString["remindCountId"];
                NJL.BLL.NJL_COMPANY bllCompany = new BLL.NJL_COMPANY();
                NJL.Model.NJL_COMPANY modelCompany = bllCompany.GetModel(shopId);
                context.Response.Write(modelCompany.VISITOR_ALERT_COUNT);

            }
            //个人空间用户信息
            else if (!string.IsNullOrEmpty(context.Request["userInfoId"]))
            {
                string useriId = context.Request["userInfoId"];
                NJL.BLL.NJL_USER bllUser = new BLL.NJL_USER();
                NJL.Model.NJL_USER modelUser;
                modelUser = bllUser.GetModel(useriId);     //查询用户信息
                NJL.BLL.NJL_PERSON bllPerson = new BLL.NJL_PERSON();
                NJL.Model.NJL_PERSON modelPerson = bllPerson.GetModelByUserId(useriId);//根据用户编号查询玩家信息
                NJL.BLL.NJL_MYFRIEND bllFriend = new BLL.NJL_MYFRIEND();
                NJL.BLL.NJL_NEWS bllNews = new BLL.NJL_NEWS();
                DataSet ds = bllFriend.GetList("NJL_MYFRIEND.NJL_USER_ID=" + useriId);
                UserInfo userinfo = new UserInfo();
                userinfo.UserName = modelUser.USER_NAME;
                if (!string.IsNullOrEmpty(modelPerson.IMAGE_CODE))
                {
                    userinfo.UserImage = BasePage.GetImageUrl(modelPerson.IMAGE_CODE, "U2");
                }
                else
                {
                    userinfo.UserImage = "/Images/avatar.jpg";
                }
                userinfo.AttentionCount = ds.Tables[0].Rows.Count.ToString();          //关注次数

                ds = bllFriend.GetList("NJL_MYFRIEND.FRIEND_USER_ID=" + useriId);      //被关注
                userinfo.AttentionCounted = ds.Tables[0].Rows.Count.ToString();        //被关注次数
                ds = bllNews.GetList("NJL_PERSON_ID='" + useriId + "'");
                userinfo.NewsCount = ds.Tables[0].Rows.Count.ToString();               //文章个数 
                ds = bllFriend.GetList("NJL_MYFRIEND.NJL_USER_ID='" + basepage.UserId + "' and NJL_MYFRIEND.FRIEND_USER_ID='" + useriId + "'");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    userinfo.IsDisPlayAttentionAndCancel = "0";//如果是自己的关注用户则显示取消关注
                }
                else
                {
                    userinfo.IsDisPlayAttentionAndCancel = "1";//如果不是自己的关注用户则显示添加关注
                }
                if (useriId == basepage.UserId)
                {
                    userinfo.IsDisPlayAttention = "0";
                }
                else
                {
                    userinfo.IsDisPlayAttention = "1";
                }
                string json = Royalsoft.Common.JsonHelper.JsonSerializer<UserInfo>(userinfo);
                context.Response.Write(json);

            }
            //分页读取游记
            else if (!string.IsNullOrEmpty(context.Request["userInfoIdPage"]) && !string.IsNullOrEmpty(context.Request["pageIndex"]))
            {
                const int PageSize = 20;
                string userId = context.Request["userInfoIdPage"];
                int pageIndex = int.Parse(context.Request["pageIndex"]);
                NJL.BLL.NJL_MYFRIEND bllFriend = new BLL.NJL_MYFRIEND();
                NJL.BLL.NJL_NEWS_COMMENT bllNewsComment = new BLL.NJL_NEWS_COMMENT();
                DataSet ds = bllFriend.GetListInNews(20, pageIndex, "(NJL_MYFRIEND.NJL_USER_ID='" + userId + "' or NJL_NEWS.NJL_PERSON_ID='" + basepage.UserId + "')");
                DataSet AllDs = bllFriend.GetListInNews("(NJL_MYFRIEND.NJL_USER_ID='" + userId + "' or NJL_NEWS.NJL_PERSON_ID='" + basepage.UserId + "')");
                int PageCount = 0;// 总页数
                PageCount = AllDs.Tables[0].Rows.Count % PageSize == 0 ? AllDs.Tables[0].Rows.Count / PageSize : AllDs.Tables[0].Rows.Count / PageSize + 1;
                StringBuilder str = new StringBuilder();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("<div class='feed-list m-top-10'>");
                    //头像
                    str.Append("<div class='feed-avatar float_l'><a href='/wanjia/" + ds.Tables[0].Rows[i]["NJL_PERSON_ID"] + "-index.html' target=\"_blank\" onmouseover=\"userInfo('" + ds.Tables[0].Rows[i]["NJL_PERSON_ID"] + "')\" onmouseout=\"hide_tips()\"><img src=\"" + (!string.IsNullOrEmpty(ds.Tables[0].Rows[i]["IMAGE_CODE"].ToString()) ? BasePage.GetImageUrl(ds.Tables[0].Rows[i]["IMAGE_CODE"].ToString(), "U1") : "/Images/avatar.jpg") + "\"  alt='" + ds.Tables[0].Rows[i]["USER_NAME"] + "' title='" + ds.Tables[0].Rows[i]["USER_NAME"] + "' width='87' height='87' /></a></div>");
                    //发布的内容
                    str.Append("<div class='feed-cont'>");
                    str.Append("<div class='pop-triangle'></div>");
                    //内容
                    str.Append("<div class='feed-hd'><span class='feed-cont-icon float_r'></span><span class='float_r'>" + string.Format("{0:MM-dd HH:mm}", ds.Tables[0].Rows[i]["CREATE_DATE_TIME3"]) + "</span> <h2><a href='/wanjia/" + ds.Tables[0].Rows[i]["NJL_PERSON_ID"] + "-index.html' target=\"_blank\" onmouseover=\"userInfo('" + ds.Tables[0].Rows[i]["NJL_PERSON_ID"] + "')\" onmouseout=\"hide_tips()\"' ><b>" + ds.Tables[0].Rows[i]["USER_NAME"] + "</b></a></h2></div>");
                    #region
                    str.Append("<div class='feed-bd'>");
                    //内容
                    str.Append("<div class='feed-ct'><h2><a href='/wanjia/" + ds.Tables[0].Rows[i]["NJL_PERSON_ID"] + "-youji-" + ds.Tables[0].Rows[i]["ID3"] + ".html' target=\"_blank\"><strong>" + ds.Tables[0].Rows[i]["NEWS_TITLE"] + "</strong></a></h2> <div class='feed-ct-cont'>" + ds.Tables[0].Rows[0]["NEWS_SUBJECT_TITLE"] + "</div><div class='feed-linkmore'> <a href='/wanjia/" + ds.Tables[0].Rows[i]["NJL_PERSON_ID"] + "-youji-" + ds.Tables[0].Rows[i]["ID3"] + ".html' target=\"_blank\">查看全文&gt;&gt;</a>  </div> </div>");
                    //评论
                    string newsId = ds.Tables[0].Rows[i]["ID3"].ToString();
                    DataSet dsComment = bllNewsComment.GetListInUser(1, "a.NJL_NEWS_ID='" + newsId + "'", "a.CREATE_DATE_TIME desc");
                    if (dsComment.Tables[0].Rows.Count > 0)
                    {
                        str.Append("<div class='feed-comment'><dl class='imglist comment'> <dt><a href='/wanjia/" + dsComment.Tables[0].Rows[0]["CREATE_USER_ID"] + "-index.html' target=\"_blank\" onmouseover=\"userInfo('" + dsComment.Tables[0].Rows[0]["CREATE_USER_ID"] + "')\" onmouseout=\"hide_tips()\"> <img src=\"" + (!string.IsNullOrEmpty(dsComment.Tables[0].Rows[0]["IMAGE_CODE"].ToString()) ? BasePage.GetImageUrl(dsComment.Tables[0].Rows[0]["IMAGE_CODE"].ToString(), "U1") : "/Images/avatar.jpg") + "\"  alt='" + dsComment.Tables[0].Rows[0]["USER_NAME"] + "' title='" + dsComment.Tables[0].Rows[0]["USER_NAME"] + "' width='67' height='50' /></a></dt> <dd>  <a href='/wanjia/" + dsComment.Tables[0].Rows[0]["CREATE_USER_ID"] + "-index.html' target=\"_blank\"> " + dsComment.Tables[0].Rows[0]["USER_NAME"] + " </a>:<span class='time'>" + string.Format("{0:MM-dd HH:mm}", dsComment.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString()) + "</span></dd>  <dd class='grayfont'>" + dsComment.Tables[0].Rows[0]["NEWS_COMMENT"] + "</dd></dl></div>");
                        DataSet dsCount = bllNewsComment.GetList("NJL_NEWS_ID='" + newsId + "'");
                        str.Append("<div class='feed-act'><p><a href='#' class='icon-com'>评论(" + dsCount.Tables[0].Rows.Count.ToString() + ")</a></p></div>");
                    }
                    str.Append("</div>");
                    #endregion
                    //底部
                    str.Append("<div class='feed-end'></div>");
                    str.Append("</div>");
                    str.Append("</div>");
                    str.Append("<div class='cleanFlex'></div>");
                }
                if (PageCount == pageIndex)
                {
                    context.Response.Write(str.ToString() + ",1");
                }
                else
                {
                    context.Response.Write(str.ToString() + ",0");
                }

            }
            //读取自己发的游记
            else if (!string.IsNullOrEmpty(context.Request["myArticleContent"]))
            {
                NJL.BLL.NJL_NEWS bllNews = new BLL.NJL_NEWS();
                NJL.BLL.NJL_NEWS_COMMENT bllNewsComment = new BLL.NJL_NEWS_COMMENT();
                DataSet ds = bllNews.GetNewsListInUser(1, "a.NJL_PERSON_ID='" + basepage.UserId + "'", "a.CREATE_DATE_TIME desc");
                StringBuilder str = new StringBuilder();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("<div class='feed-list m-top-10'>");
                    //头像
                    str.Append("<div class='feed-avatar float_l'><a href='/wanjia/" + ds.Tables[0].Rows[i]["ID1"] + "-index.html' target=\"_blank\" onmouseover=\"userInfo('" + ds.Tables[0].Rows[i]["ID1"] + "')\" onmouseout=\"hide_tips()\"><img src=\"" + (!string.IsNullOrEmpty(ds.Tables[0].Rows[i]["IMAGE_CODE"].ToString()) ? BasePage.GetImageUrl(ds.Tables[0].Rows[i]["IMAGE_CODE"].ToString(), "U1") : "/Images/avatar.jpg") + "\"  alt='" + ds.Tables[0].Rows[i]["USER_NAME"] + "' title='" + ds.Tables[0].Rows[i]["USER_NAME"] + "' width='87' height='87' /></a></div>");
                    //发布的内容
                    str.Append("<div class='feed-cont'>");
                    str.Append("<div class='pop-triangle'></div>");
                    //内容
                    str.Append("<div class='feed-hd'><span class='feed-cont-icon float_r'></span><span class='float_r'>" + string.Format("{0:MM-dd HH:mm}", ds.Tables[0].Rows[i]["CREATE_DATE_TIME"]) + "</span> <h2><a href='/wanjia/" + ds.Tables[0].Rows[i]["ID1"] + "-index.html' target=\"_blank\" onmouseover=\"userInfo('" + ds.Tables[0].Rows[i]["ID1"] + "')\" onmouseout=\"hide_tips()\"' ><b>" + ds.Tables[0].Rows[i]["USER_NAME"] + "</b></a></h2></div>");
                    #region
                    str.Append("<div class='feed-bd'>");
                    //内容
                    str.Append("<div class='feed-ct'><h2><a href='/wanjia/" + ds.Tables[0].Rows[i]["ID1"] + "-youji-" + ds.Tables[0].Rows[i]["ID"] + ".html' target=\"_blank\"><strong>" + ds.Tables[0].Rows[i]["NEWS_TITLE"] + "</strong></a></h2> <div class='feed-ct-cont'>" + ds.Tables[0].Rows[0]["NEWS_SUBJECT_TITLE"] + "</div><div class='feed-linkmore'> <a href='/wanjia/" + ds.Tables[0].Rows[i]["ID1"] + "-youji-" + ds.Tables[0].Rows[i]["ID"] + ".html' target=\"_blank\">查看全文&gt;&gt;</a>  </div> </div>");
                    //评论
                    string newsId = ds.Tables[0].Rows[i]["ID"].ToString();
                    DataSet dsComment = bllNewsComment.GetListInUser(1, "a.NJL_NEWS_ID='" + newsId + "'", "a.CREATE_DATE_TIME desc");
                    if (dsComment.Tables[0].Rows.Count > 0)
                    {
                        str.Append("<div class='feed-comment'><dl class='imglist comment'> <dt><a href='/wanjia/" + dsComment.Tables[0].Rows[0]["CREATE_USER_ID"] + "-index.html' target=\"_blank\" onmouseover=\"userInfo('" + dsComment.Tables[0].Rows[0]["CREATE_USER_ID"] + "')\" onmouseout=\"hide_tips()\"> <img src=\"" + (!string.IsNullOrEmpty(dsComment.Tables[0].Rows[0]["IMAGE_CODE"].ToString()) ? BasePage.GetImageUrl(dsComment.Tables[0].Rows[0]["IMAGE_CODE"].ToString(), "U1") : "/Images/avatar.jpg") + "\"  alt='" + dsComment.Tables[0].Rows[0]["USER_NAME"] + "' title='" + dsComment.Tables[0].Rows[0]["USER_NAME"] + "' width='67' height='50' /></a></dt> <dd>  <a href='/wanjia/" + dsComment.Tables[0].Rows[0]["CREATE_USER_ID"] + "-index.html' target=\"_blank\"> " + dsComment.Tables[0].Rows[0]["USER_NAME"] + " </a>:<span class='time'>" + string.Format("{0:MM-dd HH:mm}", dsComment.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString()) + "</span></dd>  <dd class='grayfont'>" + dsComment.Tables[0].Rows[0]["NEWS_COMMENT"] + "</dd></dl></div>");
                        DataSet dsCount = bllNewsComment.GetList("NJL_NEWS_ID='" + newsId + "'");
                        str.Append("<div class='feed-act'><p><a href='#' class='icon-com'>评论(" + dsCount.Tables[0].Rows.Count.ToString() + ")</a></p></div>");
                    }
                    str.Append("</div>");
                    #endregion
                    //底部
                    str.Append("<div class='feed-end'></div>");
                    str.Append("</div>");
                    str.Append("</div>");
                    str.Append("<div class='cleanFlex'></div>");
                }
                context.Response.Write(str.ToString());
            }
            //发布一句话
            else if (!string.IsNullOrEmpty(context.Request["addMyContent"]))
            {
                NJL.BLL.NJL_PERSON bllPerson = new BLL.NJL_PERSON();
                string content = context.Request["myContent"];
                Model.NJL_PERSON model = bllPerson.GetModelByUserId(new BasePage().UserId);
                model.SELF_EVALUATION = content;
                model.EVALUATION_UPDATE_DATE_TIME = DateTime.Now;
                if (bllPerson.Update(model))
                {
                    context.Response.Write("true");
                }
                else
                {

                }
            }
            //发表游记
            else if (!string.IsNullOrEmpty(context.Request["AddArticleContent"]))
            {
                NJL.BLL.NJL_NEWS bllNews = new BLL.NJL_NEWS();
                NJL.Model.NJL_NEWS modelNews = new Model.NJL_NEWS();
                string title = context.Request["Title"];
                string subtitle = context.Request["subTitle"];
                string content = context.Request["Content"];
                string tagText = context.Request["tag"];
                string type = context.Request["type"];
                modelNews.ID = DateTime.Now.ToString("yyyyMMddHHmmssfff") + new Random().Next(100, 999).ToString();
                modelNews.NJL_PERSON_ID = basepage.UserId;
                modelNews.TYPE_CODE = type;
                modelNews.NJL_SYS_BASE_ID = basepage.WEBSITE_CODE;
                modelNews.NEWS_TITLE = Royalsoft.Common.PageValidate.InputText(title.Trim(), 50);
                modelNews.NEWS_SUBJECT_TITLE = Royalsoft.Common.PageValidate.InputText(subtitle.Trim(), 50);
                modelNews.NEWS_TAG = PageValidate.InputText(tagText.Trim(), 100);
                modelNews.NEWS_CONTECT = content.Trim();
                modelNews.CREATE_USER_NAME = basepage.UserName;
                modelNews.CREATE_USER_ID = basepage.UserId;
                modelNews.CREATE_DATE_TIME = DateTime.Now;
                if (bllNews.Add(modelNews))
                {
                    string message;
                    if (basepage.HandleIntegral(basepage.UserId, "2", out message))
                    {

                    }
                    #region 标签处理
                    NJL.BLL.NJL_CS_TAG bllTag = new BLL.NJL_CS_TAG();
                    NJL.Model.NJL_CS_TAG modelTag = new Model.NJL_CS_TAG();
                    char[] tagtxt1 = { ',', '，' };
                    string[] tag = tagText.Trim().Split(tagtxt1);
                    foreach (string strtag in tag)
                    {
                        DataSet ds = bllTag.GetList("TAG='" + strtag + "' and NJL_SYS_BASE_ID='" + new BasePage().WEBSITE_CODE + "'");
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            modelTag = bllTag.GetModel(ds.Tables[0].Rows[0][0].ToString());
                            if (modelTag != null)
                            {
                                if (modelTag.USED_COUNT != null)
                                {
                                    modelTag.USED_COUNT += 1;
                                    if (bllTag.Update(modelTag))
                                    {
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (strtag != "")
                            {
                                modelTag.ID = DateTime.Now.ToString("yyyyMMddHHmmssfff") + new Random(Guid.NewGuid().GetHashCode()).Next(100, 999).ToString();
                                modelTag.IS_SYS_TAG = 0;
                                modelTag.TAG = strtag;
                                modelTag.CREATE_DATE_TIME = DateTime.Now;
                                modelTag.NJL_SYS_BASE_ID = new BasePage().WEBSITE_CODE;
                                modelTag.SEARCH_COUNT = 0;
                                modelTag.TAG_TYPE = "4";  //游记4
                                modelTag.USED_COUNT = 0;
                                bllTag.Add(modelTag);
                            }
                        }
                    }
                    #endregion
                    context.Response.Write("true");
                }
            }
            //获取城市编号
            else if (!string.IsNullOrEmpty(context.Request["getAreaId"]))
            {
                NJL.BLL.NJL_CUSTOM_AREA bllCustomArea = new BLL.NJL_CUSTOM_AREA();
                string cityId = context.Request["getAreaId"];
                NJL.BLL.NJL_CS_AREA bllArea = new BLL.NJL_CS_AREA();
                DataSet ds = bllArea.GetList("AREA_NAME_PINYIN='" + cityId + "'");

                if (ds.Tables[0].Rows.Count > 0)
                {
                    string json = string.Empty;
                    ds = bllCustomArea.GetList("CITY_CODE='" + ds.Tables[0].Rows[0][0].ToString() + "'");
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        List<Area> list = new List<Area>();
                        Area area;
                        foreach (DataRow row in ds.Tables[0].Rows)
                        {
                            area = new Area();
                            area.AreaID = row["ID"].ToString();
                            area.AreaName = row["CUSTOM_AREA_NAME"].ToString();
                            list.Add(area);
                        }
                        json = Royalsoft.Common.JsonHelper.JsonSerializer<List<Area>>(list);
                    }
                    else
                    {
                        json = "false";
                    }
                    context.Response.Write(json);
                    json = Royalsoft.Common.JsonHelper.CreateJsonParameters(ds.Tables[0]);
                }


            }
            //在线支付
            else if (!string.IsNullOrEmpty(context.Request["tempOrder"]))
            {
                NJL.BLL.NJL_TEMP_ORDER bllTempOrder = new BLL.NJL_TEMP_ORDER();
                NJL.Model.NJL_TEMP_ORDER modelTempOrder = new Model.NJL_TEMP_ORDER();
                modelTempOrder.ID = DateTime.Now.ToString("yyyyMMddHHmmssfff") + new Random().Next(100, 999).ToString();
                DataSet ds = bllTempOrder.GetList(1, " CONVERT(varchar(12) ,CREATE_DATE_TIME, 105)=CONVERT(varchar(12) ,getdate(), 105)", "CREATE_DATE_TIME desc");
                if (ds.Tables[0].Rows.Count == 0)
                {
                    modelTempOrder.ORDER_NO = DateTime.Now.ToString("yyMMdd") + string.Format("{0:D4}", 1);
                }
                else
                {
                    modelTempOrder.ORDER_NO = (Convert.ToInt32(ds.Tables[0].Rows[0]["ORDER_NO"].ToString().Remove(0, 1)) + 1).ToString();
                }
                modelTempOrder.ORDER_NO = "T" + modelTempOrder.ORDER_NO;
                modelTempOrder.BOOK_NAME = context.Request["userName"];
                modelTempOrder.BOOK_MOBILE = context.Request["userMobel"];
                modelTempOrder.ORDER_TOTAL = Convert.ToDecimal(context.Request["Amount"]);
                modelTempOrder.CREATE_DATE_TIME = DateTime.Now;
                modelTempOrder.CREATE_USER_ID = basepage.UserId;
                modelTempOrder.CREATE_USER_NAME = basepage.UserName;
                modelTempOrder.ORDER_STATE = 1;
                modelTempOrder.PAY_MAP_TYPE_CODE = context.Request["tempOrder"];
                modelTempOrder.PAY_USE = context.Request["txtUse"];
                modelTempOrder.NJL_SYS_BASE_ID = basepage.WEBSITE_CODE;
                if (bllTempOrder.Add(modelTempOrder))
                {
                    context.Response.Write(modelTempOrder.ORDER_NO);
                }
                else
                {
                    context.Response.Write("false");
                }
            }
            else if (!string.IsNullOrEmpty(context.Request["registerCompany"]))
            {
                NJL.BLL.NJL_COMPANY bll = new BLL.NJL_COMPANY();
                NJL.Model.NJL_COMPANY model = new Model.NJL_COMPANY();
                NJL.BLL.NJL_CS_AREA bllArea = new BLL.NJL_CS_AREA();
                NJL.Model.NJL_CS_AREA modelArea;
                NJL.BLL.NJL_CUSTOM_AREA bllCustom = new BLL.NJL_CUSTOM_AREA();
   
                model.ID = DateTime.Now.ToString("yyyyMMddHHmmssfff") + new Random().Next(100, 999).ToString();
                model.NJL_SYS_BASE_ID = basepage.WEBSITE_CODE;
                model.TYPE_CODE = "1";
                model.NJL_USER_ID = model.ID;
                model.AREA_CODE = context.Request["area"];
                model.COMPANY_NAME = context.Request["companyName"];
                model.CONTACT = context.Request["contact"];
                model.MOBILE = context.Request["mobel"];
                model.QQ = context.Request["qq"];
                model.CREATE_DATE_TIME = DateTime.Now;
                model.CREATE_USER_ID = basepage.UserId;
                model.CREATE_USER_NAME = basepage.UserName;
                model.AUDIT_STATE = 0;
                model.SORT = 0;
                model.IS_SHOW_CONTACT = 1;
                model.IS_OPEN_BOOK = 0;
                model.AUDIT_INFO_1 = "0";
                model.AUDIT_INFO_2 = "0";
                model.AUDIT_INFO_3 = "0";
                model.AUDIT_INFO_4 = "0";
                model.CLAIM_STATE = 0;
                model.IS_OPEN_BOOK = 0;
                model.IS_SHOW_CONTACT = 0;
                model.VISIT_COUNT = 0;
                model.COMMENT_COUNT = 0;
                model.USER_PASSWORD = "123456";
                model.USER_PASSWORD_MD5 = FormsAuthentication.HashPasswordForStoringInConfigFile(model.USER_PASSWORD, "MD5");
                modelArea = bllArea.GetModel(context.Request["area"]);
                DataSet ds = bll.GetAllList(1, "AREA_CODE='" + context.Request["area"] + "'", "CREATE_DATE_TIME desc");
                if (ds.Tables[0].Rows.Count == 0)
                {
                    model.COMPANY_CITY_BASE_NO = 1;
                }
                else
                {
                    model.COMPANY_CITY_BASE_NO = Convert.ToInt32(ds.Tables[0].Rows[0]["COMPANY_CITY_BASE_NO"]) + 1;
                }
                model.COMPANY_CITY_NO = modelArea.TEL_AREA_NO;
                model.COMPANY_NO = model.COMPANY_CITY_NO + string.Format("{0:D4}", model.COMPANY_CITY_BASE_NO);
                if (bll.Add(model))
                {
                    NJL.BLL.NJL_USER bllUser = new BLL.NJL_USER();
                    NJL.Model.NJL_USER modelUser = new Model.NJL_USER();
                    modelUser.ID = model.ID;
                    modelUser.NJL_SYS_BASE_ID = basepage.WEBSITE_CODE;
                    modelUser.USER_NAME = context.Request["contact"];
                    modelUser.EMAIL = model.COMPANY_NO;
                    modelUser.USER_PASSWORD = model.USER_PASSWORD;
                    modelUser.USER_PASSWORD_MD5 = model.USER_PASSWORD_MD5;
                    modelUser.TYPE_CODE = "2";
                    modelUser.CREATE_DATE_TIME = DateTime.Now;
                    if (bllUser.Add(modelUser))
                    {
                        NJL.BLL.NJL_PERSON bllPerson = new BLL.NJL_PERSON();
                        NJL.Model.NJL_PERSON modelPerson = new Model.NJL_PERSON();
                        modelPerson.ID = DateTime.Now.ToString("yyyyMMddHHmmssfff") + new Random().Next(100, 999).ToString();
                        modelPerson.NJL_SYS_BASE_ID = basepage.WEBSITE_CODE;
                        modelPerson.DEGREE = "0";
                        modelPerson.VISIT_COUNT = 0;
                        modelPerson.NJL_USER_ID = modelUser.ID;
                        modelPerson.COMMENT_COUNT = 0;
                        if (bllPerson.Add(modelPerson))
                        {

                        }

                    }

                    context.Response.Write(model.COMPANY_NO);
                }
                else
                {
                    context.Response.Write("false");
                }



            }

        }



        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}